package com.example.yiwei.crm.view.Class.listviewClass;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.entity.dockingEntity;

import java.util.List;

/**
 * Created by DHN on 2017/7/15.
 */

public class CoorSelectAdapter extends BaseAdapter{
    private Context context;
    private List<dockingEntity> beans;
    public CoorSelectAdapter(Context context, List<dockingEntity> beans) {
        // TODO Auto-generated constructor stub
        this.beans = beans;
        this.context = context;
    }
    @Override
    public int getCount() {
        return beans.size();
    }

    @Override
    public Object getItem(int position) {
        return beans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
       ViewHolder holder;
        dockingEntity bean = beans.get(position);
        LayoutInflater inflater = LayoutInflater.from(context);
        if (convertView == null) {
            convertView = inflater.inflate(
                    R.layout.layout_select_customer_item, null);
            holder = new ViewHolder();
            holder.tvName = (TextView) convertView
                    .findViewById(R.id.tv_device_name);
            holder.tvSex = (TextView) convertView
                    .findViewById(R.id.tv_device_sex);
            holder.tvAge = (TextView) convertView
                    .findViewById(R.id.tv_device_age);
            convertView.setTag(holder);
        } else {
            // 取出holder
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvName.setText(bean.getDocking_mechanism());
        holder.tvAge.setText(bean.getDocking_name());
        holder.tvSex.setVisibility(View.GONE);
        return convertView;
    }

    class ViewHolder {
        TextView tvName;
        TextView tvSex;
        TextView tvAge;
    }
}
